package com.leetcode.partition8;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

public class LC715Range模块 {

    private static final int N = (int) (1e9 + 10);
    private static SegmentTree root = new SegmentTree(1, N);

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));
    
    public static void main(String[] args) throws IOException {
        int m = Integer.parseInt(reader.readLine());
        rangeModule();
        while (m-- > 0) {
            String[] ss = reader.readLine().split(" ");
            int op = Integer.parseInt(ss[0]), l = Integer.parseInt(ss[1]), r = Integer.parseInt(ss[2]);
            if (op == 1) addRange(l, r);
            else if (op == 2) writer.write(queryRange(l, r) + "\n");
            else removeRange(l, r);
            writer.flush();
        }
        writer.flush();
    }

    public static void rangeModule() { }

    public static void addRange(int left, int right) {
        modify(root, left, right - 1, true);
    }

    public static boolean queryRange(int left, int right) {
        return query(root, left, right - 1).see;
    }
    
    public static void removeRange(int left, int right) {
        modify(root, left, right - 1, false);
    }

    private static void modify(SegmentTree root, int l, int r, boolean val) {
        if (l <= root.l && r >= root.r) {
            root.see = val;
            root.lazy = val ? 1 : -1;
        } else {
            pushdown(root);
            int mid = root.l + root.r >> 1;
            if (l <= mid) modify(root.left(), l, r, val);
            if (r > mid) modify(root.right(), l, r, val);
            pushup(root);
        }
    }

    private static SegmentTree query(SegmentTree root, int l, int r) {
        if (l <= root.l && r >= root.r) return root;
        pushdown(root);
        int mid = root.l + root.r >> 1;
        if (r <= mid) return query(root.left(), l, r);
        if (l > mid) return query(root.right(), l, r);
        SegmentTree res = new SegmentTree(-1, -1);
        res.see = query(root.left(), l, r).see && query(root.right(), l, r).see;
        return res;
    }

    private static void pushdown(SegmentTree root) {
        if (root.lazy != 0) {
            root.left().see = root.right().see = root.lazy == 1;
            root.left().lazy = root.right().lazy = root.lazy;
            root.lazy = 0;
        }
    }

    private static void pushup(SegmentTree root) {
        root.see = root.left().see && root.right().see;
    }

    private static class SegmentTree {
        //lazy为0表示没有标记，1表示true，-1表示false
        private int l, r, lazy;
        private boolean see;
        private SegmentTree lc, rc;

        public SegmentTree(int l, int r) {
            this.l = l;
            this.r = r;
        }

        public SegmentTree left() {
            if (lc == null) {
                int mid = l + r >> 1;
                lc = new SegmentTree(l, mid);
            }
            return lc;
        }

        public SegmentTree right() {
            if (rc == null) {
                int mid = l + r >> 1;
                rc = new SegmentTree(mid + 1, r);
            }
            return rc;
        }
    }
}
